package com.LachesismStorm.lachesism.downloader;

import com.LachesismStorm.lachesism.core.util.AsyncUtil;
import lombok.SneakyThrows;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class hypnotubeVideoDownloader2 {

    public static void main(String[] args) {
        String htmlString = "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/popper-fag-436.html\" title=\"Popper Fag\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/9/9/a/9/599a918e2826b-popper-fag.mp4/599a918e2826b-popper-fag.mp4-2.jpg\" alt=\"Popper Fag\" >\n" +
                "                                <span class=\"time\">03:11</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Popper Fag                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">88%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">738587</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=436\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sissy-hypno-popper-trainer-1338.html\" title=\"Sissy Hypno Popper Trainer\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/a/b/d/6/5abd6adfbc98f-sissy-hypno-popper-fragrance.mp4/5abd6adfbc98f-sissy-hypno-popper-fragrance.mp4-5.jpg\" alt=\"Sissy Hypno Popper Trainer\" >\n" +
                "                                <span class=\"time\">03:40</span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sissy Hypno Popper Trainer                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">91%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">642308</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=1338\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sex-popper-2-1869.html\" title=\"Sex &amp; Popper 2\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/b/4/2/5/52215b424517d4cc6.mp4/52215b424517d4cc6.mp4-4.jpg\" alt=\"Sex & Popper 2\" >\n" +
                "                                <span class=\"time\">21:10</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sex & Popper 2                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">90%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">625819</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=1869\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/popper-hero-sissy-498.html\" title=\"Popper Hero Sissy\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/9/b/7/2/59b72ac12f854-popper-hero-sissy.mp4/59b72ac12f854-popper-hero-sissy.mp4-8.jpg\" alt=\"Popper Hero Sissy\" >\n" +
                "                                <span class=\"time\">14:51</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Popper Hero Sissy                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">88%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">574136</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=498\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/gay-pnp-satanic-bareback-hypno-popper-trainer-3520.html\" title=\"Gay PNP Satanic Bareback Hypno Popper Trainer\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/c/7/b/8/23605c7b779a5780a.mp4/23605c7b779a5780a.mp4-6.jpg\" alt=\"Gay PNP Satanic Bareback Hypno Popper Trainer\" >\n" +
                "                                <span class=\"time\">14:20</span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Gay PNP Satanic Bareback Hypno Popper Trainer                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">84%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">562171</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=3520\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/for-my-popper-sluts-4-396.html\" title=\"For My Popper Sluts 4\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/9/8/0/3/598031747612a-for-my-popper-sluts-4.mp4/598031747612a-for-my-popper-sluts-4.mp4-1.jpg\" alt=\"For My Popper Sluts 4\" >\n" +
                "                                <span class=\"time\">03:39</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    For My Popper Sluts 4                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">92%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">536648</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=396\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/brain-damage-pmv-goon-13752.html\" title=\"Brain Damage PMV Goon\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/6/0/5/4/4/5326960542af5a6ede.mov/5326960542af5a6ede.mov-1.jpg\" alt=\"Brain Damage PMV Goon\" >\n" +
                "                                <span class=\"time\">06:04</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Brain Damage PMV Goon                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">92%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">513316</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=13752\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sissy-popper-training-1-1617.html\" title=\"Sissy Popper Training 1\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/b/0/a/f/26815b0abcb7eed44.mp4/26815b0abcb7eed44.mp4-1.jpg\" alt=\"Sissy Popper Training 1\" >\n" +
                "                                <span class=\"time\">07:55</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sissy Popper Training 1                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">91%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">381406</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=1617\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/anal-popper-warrior-2009.html\" title=\"Anal Popper Warrior\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/b/6/b/b/69745b6b98eca3447.mp4/69745b6b98eca3447.mp4-1.jpg\" alt=\"Anal Popper Warrior\" >\n" +
                "                                <span class=\"time\">12:46</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Anal Popper Warrior                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">92%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">375161</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=2009\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sissy-mind-load-79391.html\" title=\"Sissy Mind Load\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/6/7/3/7/f/97b4514a93d13655c9e3edf5a9abcdcd/97b4514a93d13655c9e3edf5a9abcdcd-1.jpg\" alt=\"Sissy Mind Load\" >\n" +
                "                                <span class=\"time\">06:44</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sissy Mind Load                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">92%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">371710</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=79391\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/eye-contact-pmv-13459.html\" title=\"Eye Contact - PMV\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/6/0/4/7/7/53269604725fd8e989.mov/53269604725fd8e989.mov-6.jpg\" alt=\"Eye Contact - PMV\" >\n" +
                "                                <span class=\"time\">06:06</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Eye Contact - PMV                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">93%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">337937</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=13459\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sex-and-popper-1846.html\" title=\"Sex And Popper\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/b/4/0/e/52215b405a32f2639.mp4/52215b405a32f2639.mp4-1.jpg\" alt=\"Sex And Popper\" >\n" +
                "                                <span class=\"time\">11:46</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sex And Popper                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">90%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">331808</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=1846\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/for-my-popper-sluts-3-1028.html\" title=\"For My Popper Sluts 3\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/a/6/9/a/5a69940ea71c7-for-my-popper-sluts-3.mp4/5a69940ea71c7-for-my-popper-sluts-3.mp4-8.jpg\" alt=\"For My Popper Sluts 3\" >\n" +
                "                                <span class=\"time\">10:27</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    For My Popper Sluts 3                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">88%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">308283</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=1028\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/slow-cock-suck-trainer-enjoy-the-cock-14197.html\" title=\"Slow Cock Suck Trainer - Enjoy the Cock\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/6/0/6/b/9/7911606b5f41112d3.mp4/7911606b5f41112d3.mp4-1.jpg\" alt=\"Slow Cock Suck Trainer - Enjoy the Cock\" >\n" +
                "                                <span class=\"time\">05:42</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Slow Cock Suck Trainer - Enjoy the Cock                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">93%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">304773</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=14197\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sissy-slut-popper-hypno-3900.html\" title=\"Sissy Slut Popper Hypno\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/c/b/2/9/139865cb26def0f35a.mov/139865cb26def0f35a.mov-8.jpg\" alt=\"Sissy Slut Popper Hypno\" >\n" +
                "                                <span class=\"time\">05:57</span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sissy Slut Popper Hypno                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">90%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">287610</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=3900\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/shemale-top-popper-training-12356.html\" title=\"Shemale Top Popper Training\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/6/0/1/7/d/422836014fbebbe512.mov/422836014fbebbe512.mov-1.jpg\" alt=\"Shemale Top Popper Training\" >\n" +
                "                                <span class=\"time\">12:11</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Shemale Top Popper Training                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">93%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">287453</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=12356\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sissy-gooner-mind-pop-13420.html\" title=\"Sissy Gooner Mind Pop\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/6/0/4/6/2/532696044efc383915.mov/532696044efc383915.mov-1.jpg\" alt=\"Sissy Gooner Mind Pop\" >\n" +
                "                                <span class=\"time\">11:32</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sissy Gooner Mind Pop                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">76%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">266369</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=13420\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/popper-hero-mia-510.html\" title=\"Popper Hero Mia\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/9/b/a/1/59ba1bd38ab3f-popper-hero-mia.mp4/59ba1bd38ab3f-popper-hero-mia.mp4-1.jpg\" alt=\"Popper Hero Mia\" >\n" +
                "                                <span class=\"time\">12:18</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Popper Hero Mia                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">89%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">247081</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=510\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/sissy-popper-trainer-i-like-that-8841.html\" title=\"Sissy Popper Trainer- I Like That\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/e/e/7/b/335575ee6faeda216d.mp4/335575ee6faeda216d.mp4-1.jpg\" alt=\"Sissy Popper Trainer- I Like That\" >\n" +
                "                                <span class=\"time\">03:41</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    Sissy Popper Trainer- I Like That                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">91%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">245236</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=8841\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>\n" +
                "</div>\n" +
                "<!-- item END -->\n" +
                "<!-- item -->\n" +
                "<div class=\"item-col col \" >\n" +
                "    <div class=\"item-inner-col inner-col\">\n" +
                "        <a href=\"https://hypnotube.com/video/for-my-popper-sluts-2-1027.html\" title=\"For My Popper Sluts 2\">\n" +
                "            <span class=\"image\">\n" +
                "                                    <img data-mb=\"shuffle-thumbs\" data-opt-timeout=\"500\" data-opt-limit=\"10\" src=\"https://cdn.hypnotube.com/thumbs/5/a/6/9/9/5a69940ea5127-for-my-popper-sluts-2.mp4/5a69940ea5127-for-my-popper-sluts-2.mp4-4.jpg\" alt=\"For My Popper Sluts 2\" >\n" +
                "                                <span class=\"time\">03:34</span>\n" +
                "                                    <span class=\"quality\">\n" +
                "                        <span class=\"quality-icon q-hd\">HD</span>\n" +
                "                    </span>\n" +
                "                            </span>\n" +
                "            <span class=\"item-info\">\n" +
                "                <span class=\"title\">\n" +
                "                    For My Popper Sluts 2                </span>\n" +
                "                <span class=\"item-stats\">\n" +
                "                    <span class=\"s-elem s-e-rate\">\n" +
                "                        <span class=\"icon i-thumbs-up\"></span>\n" +
                "                        <span class=\"sub-desc\">88%</span>\n" +
                "                    </span>\n" +
                "                    <span class=\"s-elem s-e-views\">\n" +
                "                        <span class=\"icon i-eye\"></span>\n" +
                "                        <span class=\"sub-desc\">241226</span>\n" +
                "                    </span>\n" +
                "                                                        </span>\n" +
                "            </span>\n" +
                "        </a>\n" +
                "                            <a href=\"https://hypnotube.com/action.php?action=add_favorites&id=1027\" data-mb=\"modal\" data-opt-type=\"ajax\" data-opt-close=\"Close\" data-toggle=\"tooltip\" title=\"Add to favorites\" class=\"add-to-fav\"><span class=\"icon i-plus-o\"></span></a>\n" +
                "                    </div>";
        // 定义正则表达式
        String regex = "<a href=\"([^\"]+)\" title=\"([^\"]+)\">";

        // 创建 Pattern 和 Matcher
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(htmlString);
        // 循环匹配
        while (matcher.find()) {
            String url = matcher.group(1);   // 获取 href 属性值
            AsyncUtil.executeAsync(() -> {
                a(url);
            });
        }

        System.out.println("结束");
    }

    @SneakyThrows
    public static void a(String link) {
        // 输出所有链接并处理每个链接
            System.out.println("正在处理链接: " + link);
            // 获取并打印视频链接和文件名
            String[] videoInfo = getVideoUrlFromPage(link);
            if (videoInfo != null && videoInfo.length == 2) {
                String videoUrl = videoInfo[0];
                String fileName = videoInfo[1];
                System.out.println("找到视频链接: " + videoUrl);
                System.out.println("视频文件名: " + fileName);

                // 下载视频
                downloadVideo(videoUrl, fileName);
            } else {
                System.out.println("未找到视频链接");
            }

    }

    // 获取页面中符合选择器规则的所有 href 链接
    public static List<String> getLinksFromPage(String pageUrl) throws IOException {
        List<String> links = new ArrayList<>();
        // 获取页面的HTML内容
        Document document = Jsoup.connect(pageUrl).get();
        // 定义选择器规则
        String selector = "body > section.page-wrap > section.content-sec > div > div:nth-child(2) > div > div > main > div > div > div > div > div:nth-child(n) > div > a:nth-child(1)";
        // 获取符合条件的所有 <a> 标签
        Elements linkElements = document.select(selector);
        // 遍历所有元素，提取 href 属性
        for (Element linkElement : linkElements) {
            String href = linkElement.attr("href");
            if (!href.isEmpty()) {
                links.add(href);  // 存入列表
            }
        }
        return links;
    }

    // 获取页面的 HTML 内容并提取视频链接和文件名
    public static String[] getVideoUrlFromPage(String pageUrl) throws IOException {
        // 获取页面的HTML内容
        Document document = Jsoup.connect(pageUrl).get();

        // 获取 og:title 的 content 属性
        String title = "";
        Elements metaElements = document.select("meta[property=og:title]");
        if (!metaElements.isEmpty()) {
            title = metaElements.attr("content");  // 获取 content 属性
        }

        // 定义选择器规则，提取 video 标签下的 source 标签中的 src 属性
        String videoSelector = "video#plyr_player > source";

        // 获取符合条件的 source 标签
        Elements sourceElements = document.select(videoSelector);

        // 如果找到符合条件的 source 标签，获取 src 属性
        if (!sourceElements.isEmpty()) {
            Element sourceElement = sourceElements.first();
            String videoSrc = sourceElement.attr("src");  // 获取 src 属性

            // 提取文件名并返回视频链接和文件名
            String fileName = title + ".mp4";  // 拼接文件名
            return new String[]{videoSrc, fileName};  // 返回视频链接和文件名
        }
        // 如果没有找到视频链接，返回空字符串
        return null;
    }

    // 下载视频并保存到本地
    public static void downloadVideo(String videoUrl, String fileName) throws IOException {
        // 目标文件夹路径
        String downloadDir = "/Users/yuno/Downloads/video";
        // 确保目标文件夹存在
        File dir = new File(downloadDir);
        if (!dir.exists()) {
            boolean created = dir.mkdirs();
            if (!created) {
                System.err.println("无法创建目标目录: " + downloadDir);
                return;
            }
        }

        // 设置视频文件保存路径
        File videoFile = new File(downloadDir, fileName);
        // 获取视频链接
        URL url = new URL(videoUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7");
        // 获取输入流
        try (InputStream inputStream = connection.getInputStream();
             FileOutputStream outputStream = new FileOutputStream(videoFile)) {
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            System.out.println("视频下载完成：" + videoFile.getAbsolutePath());
        }
    }
}
